package kalambury.db;

import javax.persistence.*;

/**
 * Created with IntelliJ IDEA.
 * User: damienix
 * Date: 03.11.12
 * Time: 18:38
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "score", schema = "", catalog = "kalambury")
@Entity
public class ScoreEntity {
    private int id;

    @javax.persistence.Column(name = "id")
    @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private int points;

    @javax.persistence.Column(name = "points")
    @Basic
    public int getPoints() {
        return points;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    public void incPoints() {
        this.points++;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ScoreEntity that = (ScoreEntity) o;

        if (id != that.id) return false;
        if (points != that.points) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + points;
        return result;
    }

    private UserEntity userByUser;

    @ManyToOne
    @javax.persistence.JoinColumn(name = "user", referencedColumnName = "username", nullable = false)
    public UserEntity getUserByUser() {
        return userByUser;
    }

    public void setUserByUser(UserEntity userByUser) {
        this.userByUser = userByUser;
    }
}
